package com.ruoyi.dgdData.service.impl;

import java.util.List;
import java.util.concurrent.Future;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.calculate.BezierCurveUtil;
import com.ruoyi.dgdData.domain.plat.DataDgdMzxx;
import com.ruoyi.dgdData.domain.plat.DataDgdSd;
import com.ruoyi.dgdData.mapper.DataDgdMzxxMapper;
import com.ruoyi.dgdData.service.IDataDgdMzxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

/**
 * 单轨吊满载向下制动距离测试Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@Service
public class DataDgdMzxxServiceImpl implements IDataDgdMzxxService
{
    @Autowired(required = false)
    private DataDgdMzxxMapper dataDgdMzxxMapper;

    /**
     * 查询单轨吊满载向下制动距离测试
     * 
     * @param mzxxId 单轨吊满载向下制动距离测试主键
     * @return 单轨吊满载向下制动距离测试
     */
    @Override
    public DataDgdMzxx selectDataDgdMzxxByMzxxId(Long mzxxId)
    {
        return dataDgdMzxxMapper.selectDataDgdMzxxByMzxxId(mzxxId);
    }

    /**
     * 查询单轨吊满载向下制动距离测试
     *
     * @param dataTaskId
     * @return 单轨吊满载向下制动距离测试
     */
    @Override
    public Future<List<DataDgdMzxx>> selectDataDgdMzxxByDataTaskId(Long dataTaskId) {
        List<DataDgdMzxx> dataDgdMzxxEntities = dataDgdMzxxMapper.selectDataDgdMzxxByDataTaskId(dataTaskId);
        if (!dataDgdMzxxEntities.isEmpty()) {
            dataDgdMzxxEntities.forEach(item -> {
                if (item.getSuduList() != null) {
                    // 速度曲线数据
                    item.setSdChartLineDTO(BezierCurveUtil.calPoints(item.getSuduList(), 0.1f, false));
                }
            });
        }
        return new AsyncResult<>(dataDgdMzxxEntities);
    }

    /**
     * 查询单轨吊满载向下制动距离测试列表
     * 
     * @param dataDgdMzxx 单轨吊满载向下制动距离测试
     * @return 单轨吊满载向下制动距离测试
     */
    @Override
    public List<DataDgdMzxx> selectDataDgdMzxxList(DataDgdMzxx dataDgdMzxx)
    {
        return dataDgdMzxxMapper.selectDataDgdMzxxList(dataDgdMzxx);
    }

    /**
     * 新增单轨吊满载向下制动距离测试
     * 
     * @param dataDgdMzxx 单轨吊满载向下制动距离测试
     * @return 结果
     */
    @Override
    public int insertDataDgdMzxx(DataDgdMzxx dataDgdMzxx)
    {
        dataDgdMzxx.setCreateTime(DateUtils.getNowDate());
        return dataDgdMzxxMapper.insertDataDgdMzxx(dataDgdMzxx);
    }

    /**
     * 批量新增满载向下制动距离
     *
     * @param dataDgdMzxxs
     */
    @Override
    public int batchDataDgdMzxx(List<DataDgdMzxx> dataDgdMzxxs) {
        return dataDgdMzxxMapper.batchDataDgdMzxx(dataDgdMzxxs);
    }

    /**
     * 修改单轨吊满载向下制动距离测试
     * 
     * @param dataDgdMzxx 单轨吊满载向下制动距离测试
     * @return 结果
     */
    @Override
    public int updateDataDgdMzxx(DataDgdMzxx dataDgdMzxx)
    {
        dataDgdMzxx.setUpdateTime(DateUtils.getNowDate());
        return dataDgdMzxxMapper.updateDataDgdMzxx(dataDgdMzxx);
    }

    /**
     * 变更单轨吊满载向下制动距离数据状态为2
     *
     * @param mzxxId
     * @return 结果
     */
    @Override
    public int updateDataDgdMzxxByMzxxId(Long mzxxId) {
        return dataDgdMzxxMapper.updateDataDgdMzxxByMzxxId(mzxxId);
    }

    /**
     * 变更单轨吊满载向下制动距离数据状态为2
     *
     * @param dataTaskId
     * @return 结果
     */
    @Override
    public int updateDataDgdMzxxByDataTaskId(Long dataTaskId) {
        return dataDgdMzxxMapper.updateDataDgdMzxxByDataTaskId(dataTaskId);
    }

    /**
     * 批量删除单轨吊满载向下制动距离测试
     * 
     * @param mzxxIds 需要删除的单轨吊满载向下制动距离测试主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdMzxxByMzxxIds(Long[] mzxxIds)
    {
        return dataDgdMzxxMapper.deleteDataDgdMzxxByMzxxIds(mzxxIds);
    }

    /**
     * 删除单轨吊满载向下制动距离测试信息
     * 
     * @param mzxxId 单轨吊满载向下制动距离测试主键
     * @return 结果
     */
    @Override
    public int deleteDataDgdMzxxByMzxxId(Long mzxxId)
    {
        return dataDgdMzxxMapper.deleteDataDgdMzxxByMzxxId(mzxxId);
    }
}
